﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public static partial class msg
    {
        public static dynamic deleteDiscuss(int did)
        {
            var sql = new Sql.SqlDataContext();
            var d = sql.Discuss.FirstOrDefault(row => row.did == did);
            if (d == null) return new
                {
                    success = false,
                    msg = "帖子不存在"
                };
            foreach (var d2 in sql.Discuss.Where(row => row.parentDid == did))
                deleteDiscuss(d2.did);
            sql.Discuss.DeleteOnSubmit(d);
            sql.SubmitChanges();
            return new
            {
                success = true
            };
        }
    }
}